<script language="javascript">
function insertimg(strValue){
	document.frmdanhsach.userfile.value=strValue;
	document.frmdanhsach.anhmota.src=strValue;
}
</script>
<?
$q=$_GET[q];
?>
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <?
    $dgdan=$q;
	if($dgdan==""){$dgdan=$_SESSION[path];}	
    $dirr=str_replace("*",CHR(47),$dgdan);
    $dir = dir($dirr);//List files in images directory
    $c=0;
    while (($file = $dir->read()) !== false)
    {
    $type = substr(strrchr($file, "."), 1);
    if($type!=""){
	$c=$c+1;
    if($c%4==1){echo "<tr>";}
        echo "<td align=center><a onclick=insertimg('".$dirr."/".$file."')   class=\"link-title\"><img alt=".$file." src=".$dirr."/".$file." style=width:48px;height:48px border=0 /></a>$c</td>";
    if($c%4==0){echo "</tr>";}
    }
    }$dir->close();
    ?>
    </table>